#ifndef ____Vec__
#define ____Vec__

#include <iostream>

template <int n, typename T> 

class Vec{
public:
    Vec(T f = 0);
    Vec(const Vec<n, T>&);
    T * getData();

    Vec<n, T> operator+(const Vec<n, T>&);
    Vec<n, T> operator+(const T);
    Vec<n, T> operator-(const Vec<n, T>&);
    Vec<n, T> operator*(const T);
    Vec<n, T> operator/(const T);
    const T& operator[](const int) const;
    T& operator[](const int);
  
private:
    T _data[n]; 
};

typedef Vec<2, float> vec2f;
typedef Vec<3, float> vec3f;
  
template <int n, typename T> 
Vec<n, T>::Vec(T f){
	for(int i = 0; i < n; i ++)
		_data[i] = f;
};


template <int n, typename T> 
Vec<n, T>::Vec(const Vec<n, T>& other){
	for(int i = 0; i < n; i ++)
		_data[i] = other[i];
};

template <int n, typename T> 
T* Vec<n, T>::getData(){
    return _data;
};

template <int n, typename T> 
Vec<n, T> Vec<n, T>::operator+(const Vec<n, T>& a){
	Vec<n, T> res;
	for(int i = 0; i < n; i ++)
		res[i] = a[i] + _data[i];
	return res;
};

template <int n, typename T> 
Vec<n, T> Vec<n, T>::operator+(const T a){
	Vec<n, T> res;
	for(int i = 0; i < n; i ++)
		res[i] = a + _data[i];
	return res;
};

template <int n, typename T> 
Vec<n, T> Vec<n, T>::operator-(const Vec<n, T>& b){
	Vec<n, T> res;
	for(int i = 0; i < n; i ++)
		res[i] = _data[i] - b[i];
	return res;
};

template <int n, typename T> 
Vec<n, T> Vec<n, T>::operator*(const T f){
	Vec<n, T> res;
	for(int i = 0; i < n; i ++)
		res[i] = _data[i]*f;
	return res;
};

template <int n, typename T> 
Vec<n, T> Vec<n, T>::operator/(const T f){
	Vec<n, T> res;
	for(int i = 0; i < n; i ++)
		res[i] = _data[i]/f;
	return res;
};

template <int n, typename T> 
T& Vec<n, T>::operator[](const int b){
  return _data[b];
};

template <int n, typename T> 
const T& Vec<n, T>::operator[](const int b) const{
  return _data[b];
};

template <int n, typename T> 
std::ostream& operator<<(std::ostream &output, Vec<n, T> a){
	output << "[";
	for(int i = 0; i < n; i ++)
		output << a[i] << " ";
	output << "]";
	return output;            
}

#endif